CREATE OR REPLACE
VIEW pmdv_work_vw
AS
SELECT
  workid,
  name,
  description,
  client_identifier,
  ( CASE
      WHEN end_date IS NULL
        OR end_date > SYSDATE
      THEN 'OPEN'
      ELSE 'CLOSED'
    END ) status,
  create_ip_address,
  create_terminal,
  create_osuser,
  create_date,
  created_by,
  end_ip_address,
  end_terminal,
  end_osuser,
  end_date,
  ended_by,
  ROUND( ( end_date - create_date ) * ( 60 * 24 ), 1 ) deploy_minutes,
  ROUND( ( end_date - create_date ) * ( 60 * 24 * 24 ), 1 ) deploy_seconds
FROM pmdv_work;
